
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifRegistrarOrdenCompra.java
 *
 * Created on 19-jul-2010, 12:17:15
 */

package Ordenes;


import Proveedores.jifIngresarProveedor;
import Proveedores.jifAdministrarProveedor;
import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.Utiles_Cadena;
import administracion.helper.Utiles_Fecha;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.VerificarDatos;
import administracion.propiedades.Propiedades;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.Frame;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.text.MaskFormatter;
import net.sf.jasperreports.view.JasperViewer;
import org.jdesktop.beansbinding.AbstractBindingListener;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.Binding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.AlmacenTO;
import suministros.ejb30.TO.DetalleOrdenTO;
import suministros.ejb30.TO.EmpresaTO;
import suministros.ejb30.TO.OrdenTO;
import suministros.ejb30.TO.ProveedorTO;
import suministros.ejb30.TO.RegularizacionMovimientoTO;
import suministros.ejb30.TO.SolicitudCotizacionTO;
import suministros.ejb30.TO.SubAlmacenTO;
import suministros.ejb30.TO.ZonaTO;
import suministros.ejb30.TO.TipoTO;
import suministros.ejb30.entity.DetalleOrden;
import suministros.ejb30.entity.DetalleOrdenPK;
import suministros.ejb30.entity.Orden;
import suministros.ejb30.entity.Parametros;
import suministros.ejb30.entity.Proveedor;
import suministros.ejb30.entity.SubAlmacen;
import suministros.ejb30.entity.Tipo;
import suministros.ejb30.entity.TipoCambioDiario;
import suministros.ejb30.helper.Utiles_Convertir;

/**
 *
 * @author Luis_Angel
 */
public class jifRegistrarOrdenCompra extends javax.swing.JInternalFrame {
    private ListDataIntelliHints intelliHintsProveedor;
    private List<DetalleOrdenTO> detallePedido;
    private JTableBinding jTableBinding;
    private Proveedor proveedor;
    private JDialog dialogConsolida;
    private MaskFormatter mascaraRuc;
    private String rucProveedor;
    private boolean flag_nueva;
    private OrdenTO orden_edit;
    private String id_empresa;
    private boolean isconsolida;
    private MaskFormatter mascaraFechaIngreso;
    private List<RegularizacionMovimientoTO> lista_regularizacion;
    private TipoCambioDiario tipo;

    private BigDecimal sub_total;
    private BigDecimal monto_impuesto;
    private final static BigDecimal MONTO_RDEONDEO_MAX=BigDecimal.valueOf(0.05);
    private BigDecimal monto_redondeo = BigDecimal.ZERO;
    
    /** Creates new form jifRegistrarOrdenCompra */
    public jifRegistrarOrdenCompra(boolean flag_nueva) {
        this.detallePedido = new ArrayList(1);
        sub_total = BigDecimal.ZERO;
        monto_impuesto = BigDecimal.ZERO;
        construirMascaras();
        initComponents();
        List empresas = Listas.getEmpresas();
        if(empresas.isEmpty()){
            this.jCheckBox1.setEnabled(false);
        }
        llenarComboZona();
         llenarComboTipoFormaPago();
         llenarComboTipoMoneda();
         llenarComboTipoPlantillaImpuesto();
       //  llenarComboTipoComprobante();
         llenarComboEmpresa();
         try {
            cargaHintsIndependientes();
        } catch (Exception ex) {
            Logger.getLogger(jifAdministrarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
       // this.jtfFecha.setText(this.obtieneFechaActual());
        agregaEventos();
        dialogConsolida=null;
        this.jlblMoneda.setVisible(false);
        this.jftCambio.setVisible(false);
        this.flag_nueva = flag_nueva;
        this.jbAgregarDetalle.setVisible(flag_nueva);
        this.jbEliminaDetalle.setVisible(flag_nueva);
        if(flag_nueva)
                this.jbAceptar.setText("GENERAR ORDEN");
        else
                this.jbAceptar.setText("GUARDAR CAMBIOS");
        //dsk_padre.add( this, javax.swing.JLayeredPane.DRAG_LAYER);
    }

     public void setOrdenEdit(OrdenTO orden) throws Exception{
        this.orden_edit = orden;
        this.detallePedido = GestionPedidosDelegate.getInstance().getListaDetalleOrden(this.orden_edit.getNroOrden());
        llenarDatosOrdenAEditar();
     }

     public void llenarDatosOrdenAEditar(){
             //this.jtxProveedor.setText(this.orden_edit.getNombre_proveedor());
             this.jtxRucProveedor.setText(this.orden_edit.getRuc_proveedor());
             buscarRazonSocial();
             //comprobante pago
             for( TipoTO tt :cboBeanBindingTipo1.getLista()){
               
                 if(tt.getId_tabla_tipo().equals(this.orden_edit.getForma_pago())){
                     this.jcboFormaPago.setSelectedItem(tt);
                     break;
                 }
             }
             //moneda
             for( TipoTO tt :cboBeanBindingTipo2.getLista()){
                 if(tt.getId_tabla_tipo().equals(this.orden_edit.getTipo_moneda())){
                     this.jcboMoneda.setSelectedItem(tt);
                     break;
                 }
             }
             //plantilla impuesto
             for( TipoTO tt :cboBeanBindingTipo3.getLista()){
                 if(tt.getId_tabla_tipo().equals(this.orden_edit.getPlantilla_impuesto())){
                     this.jcboPlantillaImpuesto.setSelectedItem(tt);
                     break;
                 }
             }

             /*//Tipo Comprobante
             for( TipoTO tt :cboBeanBindingTipo4.getLista()){
                 if(tt.getId_tabla_tipo().equals(this.orden_edit.getTipo_comprobante())){
                     this.jcboComprobante.setSelectedItem(tt);
                     break;
                 }
             }*/

             //zona
             for( ZonaTO tt :cboBeanBindingZona1.getLista()){
                 if(tt.getId_zona().equals(this.orden_edit.getId_zona())){
                     this.jcboZona.setSelectedItem(tt);
                     break;
                 }
             }

             //almacen
             for( AlmacenTO tt :cboBeanBindingAlmacen1.getLista()){
                 if(tt.getCodAlmacen().equalsIgnoreCase(""+this.orden_edit.getId_almacen())){
                     this.jcboAlmacen.setSelectedItem(tt);
                     break;
                 }
             }

             //ubicacion
             for( SubAlmacenTO tt :cboBeanBindingSubAlmacen1.getLista()){
                 if(tt.getCodSubAlmacen().equalsIgnoreCase(""+this.orden_edit.getId_ubicacion())){
                     this.jcboUbicacion.setSelectedItem(tt);
                     break;
                 }
             }

             this.jtaObservaciones.setText(this.orden_edit.getObservacion());
             this.jtxReferencia.setText(this.orden_edit.getReferencia());
             
             this.jtxDias.setText(""+this.orden_edit.getNum_dias());
             this.jftCambio.setText(""+this.orden_edit.getCambio_moneda());

             this.jtfFecha.setText(this.orden_edit.getFecha_emision());
             this.jlbFechaEntrega.setText(this.orden_edit.getFecha_propuesta());

            actualizaTablaDetalle(true);
     }

     private void cargaHintsIndependientes() throws Exception {
         this.intelliHintsProveedor = new ListDataIntelliHints(this.jtxProveedor, Listas.getProveedores());
        ((JList) this.intelliHintsProveedor.getDelegateComponent()).setFixedCellWidth(330);
    }

      private void construirMascaras() {
        try {
          this.mascaraRuc = new MaskFormatter("###########");
          this.mascaraFechaIngreso = new MaskFormatter("##/##/####");
        } catch (ParseException ex) {
          Logger.getLogger(jifIngresarProveedor.class.getName()).log(Level.SEVERE, null, ex);
          ex.printStackTrace();
        }
     }

      private void actualizaSubtotal() throws Exception{
         monto_redondeo = BigDecimal.ZERO;
         sub_total = BigDecimal.ZERO;
         BigDecimal monto_total = BigDecimal.ZERO;
         for (DetalleOrdenTO detalleOrdenTO : detallePedido) {
             sub_total= sub_total.add(detalleOrdenTO.getValor());
         }
         monto_impuesto = GestionPedidosDelegate.getInstance().getMontoImpuesto(((TipoTO) this.jcboPlantillaImpuesto.getSelectedItem()).getId_tabla_tipo(), sub_total);
         monto_total = monto_total.add(sub_total);
         monto_total = monto_total.add(monto_impuesto);
      //   monto_total = monto_total.add(new BigDecimal(jtfOtros.getText().trim()));
         jlblSubTotal.setText(sub_total.toPlainString());
         jlblTotal.setText(monto_total.toPlainString());
         jlblImpuesto.setText(monto_impuesto.toPlainString());
     }
      
     private void agregaEventos(){
       this.jtxDias.addKeyListener(new KeyAdapter(){
                public void keyReleased(KeyEvent e){
                    if(jtxDias.getText().trim().length()>0)
                        jlbFechaEntrega.setText(obtieneFechaSuma(jtfFecha.getText().trim(),Integer.parseInt(jtxDias.getText().trim())));
                    else
                        jlbFechaEntrega.setText("  // ");
                }
            });
       this.jtxDias.addKeyListener(new KeyAdapter(){
			public void keyTyped(KeyEvent e){
				char t=e.getKeyChar();
		    	if(!Character.isDigit(t)){
		    	        e.setKeyChar((char)2);
		             }
			}
            });

     }

      public List<DetalleOrdenTO> getDetallePedido() {
        return detallePedido;
    }

    public void setDetallePedido(List<DetalleOrdenTO> detallePedido) {
        this.detallePedido = detallePedido;

    }

     private void llenarComboEmpresa() {
        List empresas = null;
        List listaPaises_cbo = this.cboBeanBindingEmpresa1.getLista();
        listaPaises_cbo.clear();
        try
        {
              if(this.jCheckBox1.isSelected()){
                empresas = Listas.getEmpresas();
            }
            else{
                empresas = Listas.getEmpresaPrincipal();
            }

         // empresas = Listas.getEmpresas();
          this.cboBeanBindingEmpresa1.setLista(empresas);
          this.bindingGroup.bind();
          this.jcbEmpresa.updateUI();
          this.jcbEmpresa.setSelectedIndex(0);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener empresas\n" + ex.getMessage());
          ex.printStackTrace();
          
        }
      }
     
    
     private void llenarComboZona() {
            List listaZonas = null;
            List listaZonas_cbo = this.cboBeanBindingZona1.getLista();
            listaZonas_cbo.clear();
            try
            {
              listaZonas = Listas.getZonas();
              this.cboBeanBindingZona1.setLista(listaZonas);
              this.bindingGroup.bind();
              this.jcboZona.updateUI();
              this.jcboZona.setSelectedIndex(0);
            } catch (Exception ex) {
              Utiles_MensajesDialogo.mensajeAlerta("Error al obtener zonas\n" + ex.getMessage());
              ex.printStackTrace();
              Logger.getLogger(jifRegistrarOrdenCompra .class.getName()).log(Level.SEVERE, null, ex);
            }
     }

      private void llenarComboTipoFormaPago() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingTipo1.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos1 = Listas.getTipo_porTabla("Tipo_FormaPago");

          this.cboBeanBindingTipo1.setLista(listaTipos1);
          this.bindingGroup.bind();
          this.jcboFormaPago.updateUI();
          this.jcboFormaPago.setSelectedIndex(0);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Formas de Pago\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, ex);
        }
      }

    


       private void llenarComboTipoMoneda() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingTipo2.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos1 = Listas.getTipo_porTabla("Tipo_moneda");

          this.cboBeanBindingTipo2.setLista(listaTipos1);
          this.bindingGroup.bind();
          this.jcboMoneda.updateUI();
          this.jcboMoneda.setSelectedIndex(0);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Tipos Monedas\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, ex);
        }
      }

        private void llenarComboTipoPlantillaImpuesto() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingTipo3.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos1 = Listas.getTipo_porTabla("Tipo_Plantilla");

          this.cboBeanBindingTipo3.setLista(listaTipos1);
          this.bindingGroup.bind();
          this.jcboPlantillaImpuesto.updateUI();
          this.jcboPlantillaImpuesto.setSelectedIndex(0);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Tipos Plantillas Impuesto\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, ex);
        }
      }

        private String obtieneFechaActual(){
            SimpleDateFormat dateFormat=new SimpleDateFormat("dd/MM/yyyy");
            return dateFormat.format(new Date());
        }

         private String obtieneFechaSuma(String fecha,int dias){
             Calendar cal = new GregorianCalendar();
            try {
                 Date fecha_emision = new Date(VerificarDatos.verificaFecha(this.jtfFecha.getText()).getTime());
                 cal.setTimeInMillis(fecha_emision.getTime());
                 cal.add(Calendar. DATE, dias);
            } catch (Exception ex) {
                Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, ex);
            }

             return new SimpleDateFormat("dd/MM/yyyy").format(new Date(cal.getTimeInMillis()));

         //   return ""+cal.get(Calendar.DATE)+"/"+cal.get(Calendar.MONTH)+"/"+cal.get(Calendar.YEAR);

        }


         void agregaDetalleSuministro(DetalleOrdenTO detalle, boolean isEditable) throws Exception {
            try {

                this.detallePedido.add(detalle);
                actualizaTablaDetalle(isEditable);
               
                this.jbAceptar.setEnabled(true);
                
            } catch (Exception e) {
              throw e;
            }
        }

         void agregaDetalles(List<DetalleOrdenTO> detalles, boolean isEditable,List<RegularizacionMovimientoTO> lista_regularizacion) throws Exception {
            try {

                this.detallePedido=detalles;
                this.lista_regularizacion =lista_regularizacion;
                actualizaTablaRegularizada(isEditable);

            } catch (Exception e) {
              throw e;
            }
        }

       
          void establecerDatos( SolicitudCotizacionTO sc_selected){

             this.jtxProveedor.setText(sc_selected.getNombre_proveedor());
             this.jtxRucProveedor.setText(sc_selected.getRuc_proveedor());
             //comprobante pago
             for( TipoTO tt :cboBeanBindingTipo1.getLista()){
                 if(tt.getId_tabla_tipo().equals(sc_selected.getForma_pago())){
                     this.jcboFormaPago.setSelectedItem(tt);
                     break;
                 }
             }
             //plantilla impuesto
             for( TipoTO tt :cboBeanBindingTipo2.getLista()){
                 if(tt.getId_tabla_tipo().equals(sc_selected.getMoneda())){
                     this.jcboMoneda.setSelectedItem(tt);
                     break;
                 }
             }
             //moneda
             for( TipoTO tt :cboBeanBindingTipo3.getLista()){
                 if(tt.getId_tabla_tipo().equals(sc_selected.getImpuesto())){
                     this.jcboPlantillaImpuesto.setSelectedItem(tt);
                     break;
                 }
             }
         }

          void agregaDetallePedidoConsolidado(DetalleOrdenTO detalle) throws Exception {
            try {
                if(isconsolida){
                     this.detallePedido.add(detalle);
                }
                else{
                    List<DetalleOrdenTO>  l = new ArrayList(1);
                    l.add(detalle);
                   this.detallePedido= l;
                }

                isconsolida=true;
                actualizaTablaDetalle(true);
                this.jbAceptar.setEnabled(true);
            } catch (Exception e) {
              throw e;
            }
        }

           void agregaDetallePedidoConsolidadoConLicitacionMedia(DetalleOrdenTO detalle_licitado,DetalleOrdenTO detalle_sin_licitacion) throws Exception {
            try {

                this.detallePedido.add(detalle_licitado);
                 this.detallePedido.add(detalle_sin_licitacion);
                actualizaTablaDetalle(true);

            } catch (Exception e) {
              throw e;
            }
        }

    /*  private boolean verificaNoExisteSuministroEnOrden(TblBeanBindingDetalleOrden detalle) {
            boolean retorno = true;
            for (TblBeanBindingDetalleOrden det : this.detallePedido) {
              if (det.getId_suministro().equalsIgnoreCase(detalle.getId_suministro())) {
                retorno = false;
                break;
              }
            }
            return retorno;
      }*/

            private void actualizaTablaRegularizada(boolean isEditable) {
            this.bindingGroup = new BindingGroup();

            this.bindingGroup.addBindingListener(new AbstractBindingListener() {
                       @Override public void synced(Binding binding) {
                        try{
                            if(!detallePedido.isEmpty()){

                                int selec=jtDetallesOrden.getSelectedRow();
                                int columna = jtDetallesOrden.getSelectedColumn();
                                DetalleOrdenTO detaord_aux= detallePedido.get(jtDetallesOrden.convertRowIndexToModel(selec));
                                if(columna==5){

                                     detaord_aux.setValor((detaord_aux.getCantidad().multiply(detaord_aux.getPrecio())).setScale(2,RoundingMode.HALF_UP));
                                }
                                else if(columna==6){
                                    //Utiles_MensajesDialogo.mensajeAlerta(detaord_aux.getValor().divide(detaord_aux.getCantidad()).setScale(7,RoundingMode.HALF_UP).toPlainString());
                                    detaord_aux.setPrecio(detaord_aux.getValor().divide(detaord_aux.getCantidad(),7,RoundingMode.HALF_UP));
                                   // actualizaSubtotalSinImpuesto();
                                }

                                actualizaSubtotal();
                                actualizaTablaDetalle(true);
                            }

                    }catch(ArrayIndexOutOfBoundsException ex){
                    }
                        catch(Exception e){
                        e.printStackTrace();
                    }

                }
            });

            this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.detallePedido, this.jtDetallesOrden);

            JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${suministro}"));

            columnBinding0.setColumnName("ID Suministro");
            columnBinding0.setColumnClass(String.class);
            columnBinding0.setEditable(false);

            JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${descripcion}"));

            columnBinding1.setColumnName("Suministro");
            columnBinding1.setColumnClass(String.class);
            columnBinding1.setEditable(false);

            JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidad}"));

            columnBinding2.setColumnName("Cantidad");
            columnBinding2.setColumnClass(BigDecimal.class);
            columnBinding2.setEditable(false);

            JTableBinding.ColumnBinding columnBinding3= this.jTableBinding.addColumnBinding(ELProperty.create("${descripcionValor}"));;

            columnBinding3.setColumnName("Unidad");
            columnBinding3.setColumnClass(String.class);
            columnBinding3.setEditable(false);

            JTableBinding.ColumnBinding columnBinding4= this.jTableBinding.addColumnBinding(ELProperty.create("${precio}"));;

            columnBinding4.setColumnName("Precio Unitario");
            columnBinding4.setColumnClass(BigDecimal.class);
            columnBinding4.setEditable(false);

             JTableBinding.ColumnBinding columnBinding5= this.jTableBinding.addColumnBinding(ELProperty.create("${valor}"));;

            columnBinding5.setColumnName("Importe Total");
            columnBinding5.setColumnClass(BigDecimal.class);
            columnBinding5.setEditable(isEditable);

            this.bindingGroup.addBinding(this.jTableBinding);
            this.bindingGroup.bind();
             if (this.detallePedido.size() > 0 && this.jtxProveedor.getText().trim().length()>0 && this.jtxRucProveedor.getText().trim().length()>0) {
              this.jbAceptar.setEnabled(true);

             }

        }


     private void actualizaTablaDetalle(boolean isEditable) {
            this.bindingGroup = new BindingGroup();
          /*  this.bindingGroup.addBindingListener(new AbstractBindingListener() {
                       @Override public void synced(Binding binding) {
                        try{
                            if(!detallePedido.isEmpty()){
                                int selec=jtDetallesOrden.getSelectedRow();
                                DetalleOrdenTO detaord_aux= detallePedido.get(jtDetallesOrden.convertRowIndexToModel(selec));
                                detaord_aux.setValor(detaord_aux.getCantidad().multiply(detaord_aux.getPrecio()).setScale(2,RoundingMode.HALF_UP));
                                actualizaTablaDetalle(true);
                            }
                            
                    }catch(ArrayIndexOutOfBoundsException ex){
                    }
                        catch(Exception e){
                        e.printStackTrace();
                    }

                }
            });*/
            this.bindingGroup.addBindingListener(new AbstractBindingListener() {
                       @Override public void synced(Binding binding) {
                        try{
                            if(!detallePedido.isEmpty()){

                                int selec=jtDetallesOrden.getSelectedRow();
                                int columna = jtDetallesOrden.getSelectedColumn();
                                DetalleOrdenTO detaord_aux= detallePedido.get(jtDetallesOrden.convertRowIndexToModel(selec));
                                System.out.println("colum"+columna);
                                if(columna==4){
                                     System.out.println(">>>"+detaord_aux.getValor());
                                     detaord_aux.setValor((detaord_aux.getCantidad().multiply(detaord_aux.getPrecio())).setScale(2,RoundingMode.HALF_UP));
                                }
                                else if(columna==5){
                                    System.out.println(">>>>"+detaord_aux.getPrecio());
                                    //Utiles_MensajesDialogo.mensajeAlerta(detaord_aux.getValor().divide(detaord_aux.getCantidad()).setScale(7,RoundingMode.HALF_UP).toPlainString());
                                    detaord_aux.setPrecio(detaord_aux.getValor().divide(detaord_aux.getCantidad(),7,RoundingMode.HALF_UP));
                                   // actualizaSubtotalSinImpuesto();
                                }

                                actualizaSubtotal();
                                actualizaTablaDetalle(true);
                            }

                    }catch(ArrayIndexOutOfBoundsException ex){
                    }
                        catch(Exception e){
                        e.printStackTrace();
                    }

                }
            });


            this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.detallePedido, this.jtDetallesOrden);

            JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${suministro}"));

            columnBinding0.setColumnName("ID Suministro");
            columnBinding0.setColumnClass(String.class);
            columnBinding0.setEditable(false);

            JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${descripcion}"));

            columnBinding1.setColumnName("Suministro");
            columnBinding1.setColumnClass(String.class);
            columnBinding1.setEditable(false);

            JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidad}"));

            columnBinding2.setColumnName("Cantidad");
            columnBinding2.setColumnClass(BigDecimal.class);
            columnBinding2.setEditable(false);

            JTableBinding.ColumnBinding columnBinding3= this.jTableBinding.addColumnBinding(ELProperty.create("${descripcionValor}"));;

            columnBinding3.setColumnName("Unidad");
            columnBinding3.setColumnClass(String.class);
            columnBinding3.setEditable(false);

            JTableBinding.ColumnBinding columnBinding4= this.jTableBinding.addColumnBinding(ELProperty.create("${precio}"));;

            columnBinding4.setColumnName("Precio Unitario");
            columnBinding4.setColumnClass(BigDecimal.class);
            columnBinding4.setEditable(isEditable);

             JTableBinding.ColumnBinding columnBinding5= this.jTableBinding.addColumnBinding(ELProperty.create("${valor}"));;

            columnBinding5.setColumnName("Importe Total");
            columnBinding5.setColumnClass(BigDecimal.class);
            columnBinding5.setEditable(isEditable);

            this.bindingGroup.addBinding(this.jTableBinding);
            this.bindingGroup.bind();
             if (this.detallePedido.size() > 0 && this.jtxProveedor.getText().trim().length()>0 && this.jtxRucProveedor.getText().trim().length()>0) {
              this.jbAceptar.setEnabled(true);
           
             }

        }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        buttonGroup1 = new javax.swing.ButtonGroup();
        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo2 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo3 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo4 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingZona1 = new administracion.BeanBinding.CboBeanBindingZona();
        cboBeanBindingAlmacen1 = new administracion.BeanBinding.cboBeanBindingAlmacen();
        cboBeanBindingSubAlmacen1 = new administracion.BeanBinding.CboBeanBindingSubAlmacen();
        cboBeanBindingEmpresa1 = new administracion.BeanBinding.CboBeanBindingEmpresa();
        jPanel1 = new javax.swing.JPanel();
        jcboZona = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtxProveedor = new javax.swing.JTextField();
        jcboAlmacen = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jlbFechaEntrega = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jcboFormaPago = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        jcboPlantillaImpuesto = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jtxReferencia = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jcboMoneda = new javax.swing.JComboBox();
        jlblMoneda = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jcboUbicacion = new javax.swing.JComboBox();
        jtxRucProveedor = new javax.swing.JFormattedTextField(this.mascaraRuc);
        jtxDias = new javax.swing.JTextField();
        jftCambio = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jcbEmpresa = new javax.swing.JComboBox();
        jCheckBox1 = new javax.swing.JCheckBox();
        jtfFecha = new javax.swing.JFormattedTextField(this.mascaraFechaIngreso);
        jPanel2 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtaObservaciones = new javax.swing.JTextArea();
        jbCancelar = new javax.swing.JButton();
        jbAceptar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtDetallesOrden = new javax.swing.JTable();
        this.jtDetallesOrden.getTableHeader().setReorderingAllowed(false) ;
        jbEliminaDetalle = new javax.swing.JButton();
        jbAgregarDetalle = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jbAgregaImp = new javax.swing.JButton();
        jbRestaImp = new javax.swing.JButton();
        jlblSubTotal = new javax.swing.JLabel();
        jlblImpuesto = new javax.swing.JLabel();
        jlblTotal = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        setIconifiable(true);
        setTitle("Registrar Orden de Compra"); // NOI18N
        setMaximumSize(new java.awt.Dimension(214, 214));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos de la Empresa", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 204))); // NOI18N
        jPanel1.setLayout(null);

        jcboZona.setFont(new java.awt.Font("Arial", 0, 12));
        jcboZona.setToolTipText("Zona a la que se cargara el pedido"); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingZona1, eLProperty, jcboZona);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboZona.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboZonaItemStateChanged(evt);
            }
        });
        jcboZona.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboZonaActionPerformed(evt);
            }
        });
        jcboZona.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboZonaKeyPressed(evt);
            }
        });
        jPanel1.add(jcboZona);
        jcboZona.setBounds(80, 70, 161, 21);

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("SUCURSAL"); // NOI18N
        jPanel1.add(jLabel2);
        jLabel2.setBounds(10, 70, 63, 15);

        jLabel7.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/user.png"))); // NOI18N
        jLabel7.setText("PROVEEDOR"); // NOI18N
        jPanel1.add(jLabel7);
        jLabel7.setBounds(250, 160, 92, 16);

        jtxProveedor.setFont(new java.awt.Font("Arial", 0, 12));
        jtxProveedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxProveedorActionPerformed(evt);
            }
        });
        jtxProveedor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtxProveedorKeyPressed(evt);
            }
        });
        jPanel1.add(jtxProveedor);
        jtxProveedor.setBounds(350, 160, 330, 21);

        jcboAlmacen.setFont(new java.awt.Font("Arial", 0, 12));
        jcboAlmacen.setToolTipText("Almacen al que se cargara La Orden"); // NOI18N

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingAlmacen1, eLProperty, jcboAlmacen);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboAlmacen.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboAlmacenItemStateChanged(evt);
            }
        });
        jcboAlmacen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboAlmacenActionPerformed(evt);
            }
        });
        jcboAlmacen.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboAlmacenKeyPressed(evt);
            }
        });
        jPanel1.add(jcboAlmacen);
        jcboAlmacen.setBounds(80, 100, 161, 21);

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("ALMACEN"); // NOI18N
        jPanel1.add(jLabel5);
        jLabel5.setBounds(10, 100, 56, 15);

        jLabel8.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel8.setText("FECHA DE EMISION"); // NOI18N
        jPanel1.add(jLabel8);
        jLabel8.setBounds(260, 40, 106, 15);

        jLabel11.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel11.setText("PLAZO DE ENTREGA"); // NOI18N
        jPanel1.add(jLabel11);
        jLabel11.setBounds(260, 70, 113, 15);

        jLabel12.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel12.setText("FEC. ENTREGA"); // NOI18N
        jPanel1.add(jLabel12);
        jLabel12.setBounds(260, 100, 80, 15);

        jlbFechaEntrega.setFont(new java.awt.Font("Arial", 0, 12));
        jlbFechaEntrega.setForeground(new java.awt.Color(51, 51, 51));
        jlbFechaEntrega.setText(" / / "); // NOI18N
        jPanel1.add(jlbFechaEntrega);
        jlbFechaEntrega.setBounds(380, 100, 80, 15);

        jLabel15.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel15.setText("FORMA DE PAGO"); // NOI18N
        jPanel1.add(jLabel15);
        jLabel15.setBounds(470, 100, 95, 15);

        jcboFormaPago.setFont(new java.awt.Font("Arial", 0, 12));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo1, eLProperty, jcboFormaPago);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboFormaPago.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboFormaPagoItemStateChanged(evt);
            }
        });
        jcboFormaPago.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboFormaPagoKeyPressed(evt);
            }
        });
        jPanel1.add(jcboFormaPago);
        jcboFormaPago.setBounds(570, 100, 110, 21);

        jLabel17.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel17.setText("PLANT.IMPUESTO"); // NOI18N
        jPanel1.add(jLabel17);
        jLabel17.setBounds(10, 190, 101, 15);

        jcboPlantillaImpuesto.setFont(new java.awt.Font("Arial", 0, 12));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo3, eLProperty, jcboPlantillaImpuesto);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboPlantillaImpuesto.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboPlantillaImpuestoItemStateChanged(evt);
            }
        });
        jcboPlantillaImpuesto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboPlantillaImpuestoKeyPressed(evt);
            }
        });
        jPanel1.add(jcboPlantillaImpuesto);
        jcboPlantillaImpuesto.setBounds(120, 190, 230, 21);

        jLabel18.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel18.setText("RUC"); // NOI18N
        jPanel1.add(jLabel18);
        jLabel18.setBounds(10, 160, 24, 15);

        jLabel19.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel19.setText("REFERENCIA"); // NOI18N
        jPanel1.add(jLabel19);
        jLabel19.setBounds(260, 130, 70, 15);

        jtxReferencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxReferenciaActionPerformed(evt);
            }
        });
        jPanel1.add(jtxReferencia);
        jtxReferencia.setBounds(350, 130, 330, 20);

        jLabel22.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel22.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/apps/xcalc.png"))); // NOI18N
        jLabel22.setText("MONEDA"); // NOI18N
        jPanel1.add(jLabel22);
        jLabel22.setBounds(470, 40, 70, 16);

        jcboMoneda.setFont(new java.awt.Font("Arial", 0, 12));
        jcboMoneda.setForeground(new java.awt.Color(51, 51, 51));

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo2, eLProperty, jcboMoneda);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboMoneda.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboMonedaItemStateChanged(evt);
            }
        });
        jcboMoneda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboMonedaActionPerformed(evt);
            }
        });
        jcboMoneda.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboMonedaKeyPressed(evt);
            }
        });
        jPanel1.add(jcboMoneda);
        jcboMoneda.setBounds(570, 40, 110, 21);

        jlblMoneda.setFont(new java.awt.Font("Arial", 1, 12));
        jlblMoneda.setText("CAMBIO MONEDA"); // NOI18N
        jPanel1.add(jlblMoneda);
        jlblMoneda.setBounds(470, 70, 99, 15);

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel6.setText("UBICACION"); // NOI18N
        jPanel1.add(jLabel6);
        jLabel6.setBounds(10, 130, 63, 15);

        jcboUbicacion.setFont(new java.awt.Font("Arial", 0, 12));
        jcboUbicacion.setToolTipText("Ubicaciones dentero de un Almacen"); // NOI18N

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingSubAlmacen1, eLProperty, jcboUbicacion);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboUbicacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboUbicacionActionPerformed(evt);
            }
        });
        jcboUbicacion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboUbicacionKeyPressed(evt);
            }
        });
        jPanel1.add(jcboUbicacion);
        jcboUbicacion.setBounds(80, 130, 160, 21);

        jtxRucProveedor.setFont(new java.awt.Font("Arial", 0, 12));
        jtxRucProveedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxRucProveedorActionPerformed(evt);
            }
        });
        jPanel1.add(jtxRucProveedor);
        jtxRucProveedor.setBounds(80, 160, 160, 21);

        jtxDias.setFont(new java.awt.Font("Arial", 0, 12));
        jtxDias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxDiasActionPerformed(evt);
            }
        });
        jPanel1.add(jtxDias);
        jtxDias.setBounds(380, 70, 57, 21);

        jftCambio.setFont(new java.awt.Font("Arial", 0, 12));
        jftCambio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftCambioActionPerformed(evt);
            }
        });
        jPanel1.add(jftCambio);
        jftCambio.setBounds(570, 70, 44, 21);

        jLabel20.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel20.setText("EMPRESA");
        jPanel1.add(jLabel20);
        jLabel20.setBounds(10, 40, 56, 15);

        jcbEmpresa.setEnabled(false);

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingEmpresa1, eLProperty, jcbEmpresa);
        bindingGroup.addBinding(jComboBoxBinding);

        jcbEmpresa.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcbEmpresaItemStateChanged(evt);
            }
        });
        jPanel1.add(jcbEmpresa);
        jcbEmpresa.setBounds(80, 40, 161, 20);

        jCheckBox1.setFont(new java.awt.Font("Arial", 1, 12));
        jCheckBox1.setText("OTRAS EMPRESAS");
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });
        jPanel1.add(jCheckBox1);
        jCheckBox1.setBounds(130, 10, 133, 23);

        jtfFecha.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfFechaKeyPressed(evt);
            }
        });
        jPanel1.add(jtfFecha);
        jtfFecha.setBounds(380, 40, 80, 20);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Observaciones", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 204))); // NOI18N

        jLabel21.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel21.setText("OBSERVACION"); // NOI18N

        jtaObservaciones.setColumns(20);
        jtaObservaciones.setFont(new java.awt.Font("Arial", 0, 12));
        jtaObservaciones.setRows(5);
        jScrollPane1.setViewportView(jtaObservaciones);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel21)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 353, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(221, 221, 221))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel21))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE))
                .addContainerGap())
        );

        jbCancelar.setFont(new java.awt.Font("Arial", 0, 12));
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbCancelar.setMnemonic('C');
        jbCancelar.setText("CERRAR"); // NOI18N
        jbCancelar.setToolTipText("Cancelar la Operacion"); // NOI18N
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });
        jbCancelar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbCancelarKeyPressed(evt);
            }
        });

        jbAceptar.setFont(new java.awt.Font("Arial", 0, 12));
        jbAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbAceptar.setMnemonic('A');
        jbAceptar.setText("GENERAR ORDEN"); // NOI18N
        jbAceptar.setToolTipText("Registrar el pedido"); // NOI18N
        jbAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAceptarActionPerformed(evt);
            }
        });
        jbAceptar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbAceptarKeyPressed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Detalles", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 204))); // NOI18N

        jtDetallesOrden.setFont(new java.awt.Font("Arial", 0, 12));
        jtDetallesOrden.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Codigo", "Descripcion del Suministro", "Cantidad", "Unidad", "Precio Unitario", "Importe Total"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Float.class, java.lang.String.class, java.lang.Float.class, java.lang.Float.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jtDetallesOrden);
        jtDetallesOrden.getColumnModel().getColumn(0).setHeaderValue("Codigo");
        jtDetallesOrden.getColumnModel().getColumn(1).setHeaderValue("Descripcion del Suministro");
        jtDetallesOrden.getColumnModel().getColumn(2).setHeaderValue("Cantidad");
        jtDetallesOrden.getColumnModel().getColumn(3).setHeaderValue("Unidad");
        jtDetallesOrden.getColumnModel().getColumn(4).setHeaderValue("Precio Unitario");
        jtDetallesOrden.getColumnModel().getColumn(5).setHeaderValue("Importe Total");

        jbEliminaDetalle.setFont(new java.awt.Font("Arial", 0, 12));
        jbEliminaDetalle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/remove.png"))); // NOI18N
        jbEliminaDetalle.setMnemonic('E');
        jbEliminaDetalle.setText("ELIMINAR");
        jbEliminaDetalle.setToolTipText("Eliminar el detalle seleccionado");
        jbEliminaDetalle.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jbEliminaDetalle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbEliminaDetalleActionPerformed(evt);
            }
        });
        jbEliminaDetalle.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbEliminaDetalleKeyPressed(evt);
            }
        });

        jbAgregarDetalle.setFont(new java.awt.Font("Arial", 0, 12));
        jbAgregarDetalle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/add.png"))); // NOI18N
        jbAgregarDetalle.setMnemonic('G');
        jbAgregarDetalle.setText("AGREGAR");
        jbAgregarDetalle.setToolTipText("Agregar un detalle al pedido");
        jbAgregarDetalle.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jbAgregarDetalle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAgregarDetalleActionPerformed(evt);
            }
        });
        jbAgregarDetalle.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbAgregarDetalleKeyPressed(evt);
            }
        });

        jButton1.setText("REGULARIZAR");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 568, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jbAgregarDetalle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbEliminaDetalle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbAgregarDetalle, jbEliminaDetalle});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbAgregarDetalle)
                .addGap(5, 5, 5)
                .addComponent(jbEliminaDetalle))
        );

        jLabel9.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText("AJUSTE IMP.");

        jbAgregaImp.setText("+");
        jbAgregaImp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAgregaImpActionPerformed(evt);
            }
        });

        jbRestaImp.setText("-");
        jbRestaImp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbRestaImpActionPerformed(evt);
            }
        });

        jlblSubTotal.setBackground(new java.awt.Color(204, 204, 204));
        jlblSubTotal.setFont(new java.awt.Font("Tahoma", 1, 11));
        jlblSubTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlblSubTotal.setText("0.00");
        jlblSubTotal.setEnabled(false);
        jlblSubTotal.setOpaque(true);
        jlblSubTotal.setPreferredSize(new java.awt.Dimension(24, 17));

        jlblImpuesto.setBackground(new java.awt.Color(204, 204, 204));
        jlblImpuesto.setFont(new java.awt.Font("Tahoma", 1, 11));
        jlblImpuesto.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlblImpuesto.setText("0.00");
        jlblImpuesto.setEnabled(false);
        jlblImpuesto.setOpaque(true);
        jlblImpuesto.setPreferredSize(new java.awt.Dimension(24, 17));

        jlblTotal.setBackground(new java.awt.Color(204, 204, 204));
        jlblTotal.setFont(new java.awt.Font("Tahoma", 1, 11));
        jlblTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jlblTotal.setText("0.00");
        jlblTotal.setEnabled(false);
        jlblTotal.setOpaque(true);
        jlblTotal.setPreferredSize(new java.awt.Dimension(24, 17));

        jLabel13.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel13.setText("TOTAL");

        jLabel4.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("IMPUESTO");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel3.setText("SUB_TOTAL");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 703, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 703, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 475, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jlblTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jlblImpuesto, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jbAgregaImp)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jbRestaImp))
                                    .addComponent(jlblSubTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(8, 8, 8))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(200, 200, 200)
                        .addComponent(jbAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbCancelar)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbAceptar, jbCancelar});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbAgregaImp)
                            .addComponent(jLabel9)
                            .addComponent(jbRestaImp))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jlblSubTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jlblImpuesto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel4))
                        .addGap(9, 9, 9)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
                            .addComponent(jlblTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbAceptar)
                    .addComponent(jbCancelar))
                .addContainerGap())
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void verReporteOrden(){
          Map parametros = new HashMap();
          parametros.put("nroOrden","C-2010-07-00001");
        try {
             JasperViewer.viewReport(GestionPedidosDelegate.getInstance().generarReporte("reporte_orden.jasper", parametros),false);
        } catch (Exception ex) {
            Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


    private void jcboZonaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboZonaActionPerformed
        if(this.jcboZona.getSelectedIndex()>=0)
         this.llenarComboAlmacen();
}//GEN-LAST:event_jcboZonaActionPerformed

    private void jcboZonaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboZonaKeyPressed

        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jcboAlmacen.requestFocus();
        }
}//GEN-LAST:event_jcboZonaKeyPressed

    private void jtxProveedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxProveedorActionPerformed
 
            buscarRazonSocial();
            this.jcboFormaPago.requestFocus();
          //   this.detallePedido.clear();
           // this.actualizaTablaDetalle();
      
    }//GEN-LAST:event_jtxProveedorActionPerformed

    public void establecerProveedor(String ruc){
        this.jtxRucProveedor.setText(ruc);
        this.buscarRazonSocial();
    }
     private void buscarRazonSocial()
      {
        ProveedorTO pro;
        if (this.jtxRucProveedor.getText().trim().length() < 1) {
              try { pro = (ProveedorTO)this.intelliHintsProveedor.getSelectedHint();
              } catch (NullPointerException ex) {
                pro = null;
              }
            }
        else {
          pro = Listas.getProveedorcodigo(this.jtxRucProveedor.getText().trim());
        }
        if (pro == null) {
          Utiles_MensajesDialogo.mensajeError("El proveedor no existe!");
          this.jtxRucProveedor.setText("");
          pro = null;
        }
        else {
          this.proveedor = Utiles_Convertir.convertirToProveedor_ProveedorTO(pro);
          this.jtxProveedor.setText(pro.getRazon() + " - " + pro.getCodProveedor());
          this.jtxRucProveedor.setText(pro.getCodProveedor());
          this.rucProveedor=pro.getCodProveedor();
        }

      }
     
    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed
       
       this.dialogConsolida=null;
       this.dispose();
}//GEN-LAST:event_jbCancelarActionPerformed

    private void jbCancelarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbCancelarKeyPressed
       
        
}//GEN-LAST:event_jbCancelarKeyPressed


    private String verificarDatos(){
        String mensaje = "";
        if(jtfFecha.getText().trim().equalsIgnoreCase("/  /"))
            mensaje+= "Ingrese el campo Fecha de Emision\n";
        if(jtxDias.getText().trim().length()==0)
            mensaje+= "Ingrese el campo Plazo de Entrega\n";
        else if(Utiles_Cadena.noEsDigito(jtxDias.getText().trim()))
                mensaje += "El campo Plazo de entrega debe ser un numero\n";
        if( this.rucProveedor==null)
            mensaje+= "Seleccione un proveedor\n";
        if(detallePedido.isEmpty())
            mensaje+= "Especifique como minimo un detalle de orden\n";
        return mensaje;
    }
    private void jbAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAceptarActionPerformed
         String mensaje = verificarDatos();

         if(mensaje.length()==0){
                 if(flag_nueva){
                     if(jcboMoneda.getSelectedIndex()==1){
                         try {
                             tipo=  GestionPedidosDelegate.getInstance().getTipoCambio(jtfFecha.getText().trim());
                            if(tipo==null){
                                 Utiles_MensajesDialogo.mensajeAlerta("El dia no tiene registrado un cambio de moneda!!");
                                 return;
                            }
                        } catch (Exception ex) {
                            Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }
               
                     int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de Guardar Orden de Compra?",
              "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
                    if(res==javax.swing.JOptionPane.YES_OPTION){
                            try {
                                        Parametros param = Listas.getParametrosID("SU1");
                                    String ano = param.getParam1();
                                    String mes = param.getParam2();

                                    Date fecha_orden = new Date(VerificarDatos.verificaFecha(this.jtfFecha.getText()).getTime());
                                    Utiles_Fecha utf = new Utiles_Fecha(fecha_orden);
                                    if ((!utf.getAnio().equalsIgnoreCase(ano)) || (!utf.getMes().equalsIgnoreCase(mes))) {
                                      throw new Exception("La fecha debe coincidir con el mes actual: " + ano + " - " + mes);
                                    }

                                        String nro_orden=null;
                                            //
                                                List<DetalleOrdenTO> orden_sin_licitacion= new ArrayList();

                                                    nro_orden = verificaGuardaDatos(this.detallePedido);
                                                    if(nro_orden!=null){
                                                     verVentanaReporte(nro_orden);
                                                }
                                        if(this.lista_regularizacion!=null){
                                            GestionPedidosDelegate.getInstance().regularizaMovimientos(this.lista_regularizacion,nro_orden);
                                        }
                                        limpiar();



                                 }
                                catch (Exception e) {
                                  Utiles_MensajesDialogo.mensajeError(e.getMessage());
                                }
                    }
                 }
                 else{
                     int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de Modificar Orden de Compra?",
              "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
                    if(res==javax.swing.JOptionPane.YES_OPTION){
                        try {
                             //if(verificaModificaDatos())
                            verificaModificaDatos();
                                //verVentanaReporte(this.orden_edit.getNroOrden());

                        } catch (Exception ex) {
                           Utiles_MensajesDialogo.mensajeError(ex.getMessage());
                        }


                    }
                 }
         }
         else{
             Utiles_MensajesDialogo.mensajeAlerta(mensaje);
         }

       
    }//GEN-LAST:event_jbAceptarActionPerformed

    private void verVentanaReporte(String nro_orden){
          Frame frm = JOptionPane.getFrameForComponent((JInternalFrame)this);
        JDialog dialog = new JDialog(frm, true);
        dialog.setLocationRelativeTo(frm);
       // dialog.setTitle("Orden registrada : " + cod_orden);
        dialog.setDefaultCloseOperation(0);
         int tipo_orden =  Listas.getTipo_porTablaYCodigo("tipo_Orden","01").getId_tabla_tipo();
        jpVisualizaNuevaOrden panel = new jpVisualizaNuevaOrden(dialog,nro_orden,tipo_orden,this.rucProveedor);
        dialog.add(panel);
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
    }


     private boolean verificaModificaDatos() throws Exception{
        
        List detalle_orden = new ArrayList(1);
        Parametros param = Listas.getParametrosID("SU1");
        String ano = param.getParam1();
        String mes = param.getParam2();

        ZonaTO obj_zona=(ZonaTO)this.jcboZona.getSelectedItem();
        String cod_zona=obj_zona.getId_zona();
        AlmacenTO obj_almacen=(AlmacenTO)this.jcboAlmacen.getSelectedItem();
        String cod_almacen=obj_almacen.getCodAlmacen();

        String observacion=this.jtaObservaciones.getText();
        String referencia=this.jtxReferencia.getText();
     
        BigDecimal cambio_moneda;
         cambio_moneda= tipo.getTipoCambio();

        Tipo formaPago_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboFormaPago.getSelectedItem());
        Tipo plantillaImpuesto_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboPlantillaImpuesto.getSelectedItem());
//        Tipo comprobantePago_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboComprobante.getSelectedItem());
        Tipo moneda_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboMoneda.getSelectedItem());
    
        SubAlmacen ubicacion= Utiles_Convertir.convertirTosubAlmacen_subAlmacenTO((SubAlmacenTO)this.jcboUbicacion.getSelectedItem());

         Date fecha_emision = new Date(VerificarDatos.verificaFecha(this.jtfFecha.getText()).getTime());
         Date fecha_entrega = new Date(VerificarDatos.verificaFecha(this.jlbFechaEntrega.getText()).getTime());

         Orden cab_orden = new Orden();
         cab_orden.setCodProveedor(new Proveedor(this.jtxRucProveedor.getText().trim()));

         cab_orden.setIdUbicacion(ubicacion);
         cab_orden.setIdAlmacen(cod_almacen);
         cab_orden.setIdZona(cod_zona);

         cab_orden.setCambioMoneda(cambio_moneda);
         cab_orden.setReferencia(referencia);
         cab_orden.setObservacion(observacion);

         cab_orden.setPlantillaImpuesto(plantillaImpuesto_tipo);
        // cab_orden.setComprobantePago(comprobantePago_tipo);
         cab_orden.setFormaPago(formaPago_tipo);
         cab_orden.setTipoMoneda(moneda_tipo);
      
         cab_orden.setFechaemision(fecha_emision);
         cab_orden.setFechapropuesta(fecha_entrega);

         cab_orden.setAno(ano);
         cab_orden.setMes(mes);
         cab_orden.setNroOrden(this.orden_edit.getNroOrden());
         cab_orden.setEmpresa(Utiles_Convertir.convertirToEmpresa_EmpresaTO((EmpresaTO)this.jcbEmpresa.getSelectedItem()));
         cab_orden.setUsuario(Propiedades.getUsuario());
         cab_orden.setMac(Propiedades.getMac());
         
         cab_orden.setValorImpuesto(BigDecimal.ZERO);

         BigDecimal val_total = BigDecimal.ZERO;
        int correlativo=1;
          for (DetalleOrdenTO deta : this.detallePedido) {
              DetalleOrden detall = new DetalleOrden();
              detall.setDetalleOrdenPK(new DetalleOrdenPK("1", correlativo));

              detall.setCantidad(deta.getCantidad());
              detall.setCantidadIngresada(BigDecimal.ZERO);
              
              detall.setIDSuministro(deta.getSuministro());
              detall.setIdZona(cod_zona);
             // detall.setCantidadIngresada(new BigDecimal(0));
              detall.setPrecioUnitario(deta.getPrecio());

              detalle_orden.add(detall);
              correlativo++;
              val_total = val_total.add(deta.getValor());
         }
         cab_orden.setValorTotal(val_total);
         return GestionPedidosDelegate.getInstance().modificarOrden(cab_orden, detalle_orden);

     }

     private String verificaGuardaDatos( List<DetalleOrdenTO> detalle_orden_actual) throws Exception{
          List detalle_orden = new ArrayList(1);
          
        Parametros param = Listas.getParametrosID("SU1");
        String ano = param.getParam1();
        String mes = param.getParam2();

        ZonaTO obj_zona=(ZonaTO)this.jcboZona.getSelectedItem();
        String cod_zona=obj_zona.getId_zona();
        AlmacenTO obj_almacen=(AlmacenTO)this.jcboAlmacen.getSelectedItem();
        String cod_almacen=obj_almacen.getCodAlmacen();
       
        String observacion=this.jtaObservaciones.getText();
        String referencia=this.jtxReferencia.getText();
        //String compromiso=this.jftCompromiso.getText();
        BigDecimal cambio_moneda;

        if(tipo!=null)
             cambio_moneda= tipo.getTipoCambio();
        else
            cambio_moneda = BigDecimal.ONE;
        
        Tipo formaPago_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboFormaPago.getSelectedItem());
        Tipo plantillaImpuesto_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboPlantillaImpuesto.getSelectedItem());
//        Tipo comprobantePago_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboComprobante.getSelectedItem());
        Tipo moneda_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.jcboMoneda.getSelectedItem());
        Tipo orden_tipo = Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)Listas.getTipo_porTabla("tipo_Orden").get(0));
       
        SubAlmacen ubicacion= Utiles_Convertir.convertirTosubAlmacen_subAlmacenTO((SubAlmacenTO)this.jcboUbicacion.getSelectedItem());
        
         Date fecha_emision = new Date(VerificarDatos.verificaFecha(this.jtfFecha.getText()).getTime());
         Date fecha_entrega = new Date(VerificarDatos.verificaFecha(this.jlbFechaEntrega.getText()).getTime());
         
         Orden cab_orden = new Orden();
         cab_orden.setCodProveedor(new Proveedor(this.jtxRucProveedor.getText().trim()));
         
         cab_orden.setIdUbicacion(ubicacion);
         cab_orden.setIdAlmacen(cod_almacen);
         cab_orden.setIdZona(cod_zona);
        
         cab_orden.setCambioMoneda(cambio_moneda);
         cab_orden.setReferencia(referencia);
         cab_orden.setObservacion(observacion);
         //cab_orden.setCompromiso(compromiso);
         
         cab_orden.setPlantillaImpuesto(plantillaImpuesto_tipo);
//         cab_orden.setComprobantePago(comprobantePago_tipo);
         cab_orden.setFormaPago(formaPago_tipo);
         cab_orden.setTipoMoneda(moneda_tipo);
         cab_orden.setTipoorden(orden_tipo);
        
         cab_orden.setFechaemision(fecha_emision);
         cab_orden.setFechapropuesta(fecha_entrega);

         cab_orden.setAno(ano);
         cab_orden.setMes(mes);

         cab_orden.setEmpresa(Utiles_Convertir.convertirToEmpresa_EmpresaTO((EmpresaTO)this.jcbEmpresa.getSelectedItem()));
         cab_orden.setUsuario(Propiedades.getUsuario());
         cab_orden.setMac(Propiedades.getMac());
         cab_orden.setValorImpuesto(BigDecimal.ZERO);
        

         cab_orden.setMonto_utilizado(monto_redondeo);
         BigDecimal val_total = BigDecimal.ZERO;

         int correlativo=1;
          for (DetalleOrdenTO deta : detalle_orden_actual) {
              DetalleOrden detall = new DetalleOrden();
              detall.setDetalleOrdenPK(new DetalleOrdenPK("1", correlativo));
              detall.setSub_total(deta.getValor());
              detall.setCantidad(deta.getCantidad());
              detall.setCantidadIngresada(BigDecimal.ZERO);
              //detall.setCodPedido(deta.getPedido());
              detall.setIDSuministro(deta.getSuministro());
              //detall.setId_unidad_organica(deta.getUnidad_organica());
            //  detall.setIdCodPresupuestal(deta.getCodPresupuesta());
            //  detall.setIdCodInversion(deta.getCodInversion());
             // detall.setCantidadIngresada(new BigDecimal(0));

           //   detall.setIdCuentaContableInversion(deta.getCtaCtble());
            //  detall.setCodCentroCosto(deta.getCentroCostos());
            //  detall.setIdZona(deta.getZona());
            //  detall.setIdLocalidad(deta.getLocalidad());
              //detall.setIdproyecto(deta.getIdproyecto());
              //detall.setPrecioUnitario(deta.getPrecio());
              detall.setSub_total(deta.getCantidad().multiply(deta.getPrecio()));
              detall.setPrecioUnitario((deta.getPrecio()!=null)?deta.getPrecio():BigDecimal.ZERO);
              detall.setIdZona(cod_zona);
              
              detalle_orden.add(detall);
              correlativo++;
              val_total = val_total.add(deta.getValor());
              //id_proyecto=deta.getIdproyecto();
         }
         cab_orden.setValorTotal(val_total);
          //cab_orden.setId_licitacion(id_licitacion);
          //cab_orden.setIdproyecto(id_proyecto);
       //  int tipo =  Listas.getTipo_porTablaYCodigo("tipo_Orden","01").getId_tabla_tipo();
         return GestionPedidosDelegate.getInstance().insertarOrden(cab_orden, detalle_orden);
         
     }

     public void limpiar(){
        this.jcboZona.setSelectedIndex(0);
        this.jcboFormaPago.setSelectedIndex(0);
        this.jcboPlantillaImpuesto.setSelectedIndex(0);
        //this.jcboComprobante.setSelectedIndex(0);
        this.jcboMoneda.setSelectedIndex(0);
        this.jcboAlmacen.setSelectedIndex(0);
        this.jcboUbicacion.setSelectedIndex(0);
        this.jtxProveedor.setText("");
        this.jtxRucProveedor.setText("");
        this.jtxDias.setText("");
        this.jtxReferencia.setText("");
        this.jtaObservaciones.setText("");
        this.jftCambio.setText("");
        this.rucProveedor=null;
       // this.jftCompromiso.setText("");
        this.detallePedido.clear();
        this.actualizaTablaDetalle(true);
        this.lista_regularizacion=null;
        tipo=null;
   

     }
     
    private void jbAceptarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbAceptarKeyPressed
       
     
}//GEN-LAST:event_jbAceptarKeyPressed

    private void jcboAlmacenKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboAlmacenKeyPressed
        
      if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jcboUbicacion.requestFocus();
        }
}//GEN-LAST:event_jcboAlmacenKeyPressed

    private void jcboUbicacionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboUbicacionKeyPressed
       
         if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jtxProveedor.requestFocus();
        }
    }//GEN-LAST:event_jcboUbicacionKeyPressed

    private void jcboZonaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboZonaItemStateChanged

        
    }//GEN-LAST:event_jcboZonaItemStateChanged

    private void jcboAlmacenItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboAlmacenItemStateChanged
       
    }//GEN-LAST:event_jcboAlmacenItemStateChanged

    private void jcboMonedaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboMonedaItemStateChanged
        
         
    }//GEN-LAST:event_jcboMonedaItemStateChanged

    private void jcboFormaPagoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboFormaPagoItemStateChanged
        
        
    }//GEN-LAST:event_jcboFormaPagoItemStateChanged

    private void jtxDiasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxDiasActionPerformed
        
        this.jcboPlantillaImpuesto.requestFocus();
    }//GEN-LAST:event_jtxDiasActionPerformed

    private void jcboPlantillaImpuestoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboPlantillaImpuestoItemStateChanged
          try {
            System.out.println(">>"+sub_total.doubleValue());
            actualizaSubtotal();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        
    }//GEN-LAST:event_jcboPlantillaImpuestoItemStateChanged

    private void jtxReferenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxReferenciaActionPerformed
        
        this.jcboMoneda.requestFocus();
    }//GEN-LAST:event_jtxReferenciaActionPerformed

    private void jftCambioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftCambioActionPerformed
        
        this.jbAgregarDetalle.requestFocus();
    }//GEN-LAST:event_jftCambioActionPerformed

    private void jtxRucProveedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxRucProveedorActionPerformed
        
        if (this.jtxRucProveedor.getText().trim().length() < 1)
            this.jcboFormaPago.requestFocus();
        else
            buscarRazonSocial();
    }//GEN-LAST:event_jtxRucProveedorActionPerformed

    private void jcboAlmacenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboAlmacenActionPerformed

        if(this.jcboAlmacen.getSelectedIndex()>=0)
                this.llenarComboUbicacion();
    }//GEN-LAST:event_jcboAlmacenActionPerformed

    private void jcboFormaPagoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboFormaPagoKeyPressed

        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jtxDias.requestFocus();
        }
    }//GEN-LAST:event_jcboFormaPagoKeyPressed

    private void jcboPlantillaImpuestoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboPlantillaImpuestoKeyPressed
       
       
    }//GEN-LAST:event_jcboPlantillaImpuestoKeyPressed

    private void jcboMonedaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboMonedaKeyPressed
       
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            if(this.jcboMoneda.getSelectedIndex()!=0){
            this.jlblMoneda.setVisible(true);
            this.jftCambio.setVisible(true);
            this.jftCambio.requestFocus();
            }
            else{
                 this.jlblMoneda.setVisible(false);
                this.jftCambio.setVisible(false);
            }
        }

    }//GEN-LAST:event_jcboMonedaKeyPressed

    private void jtxProveedorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxProveedorKeyPressed
         if (this.jtxRucProveedor.getText().trim().length() > 0)
            this.jtxRucProveedor.setText("");
    }//GEN-LAST:event_jtxProveedorKeyPressed

    private void jcboUbicacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboUbicacionActionPerformed
       
    }//GEN-LAST:event_jcboUbicacionActionPerformed

    private void jcboMonedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMonedaActionPerformed
        if(this.jcboMoneda.getSelectedIndex()!=0){
          //this.jlblMoneda.setVisible(true);
          //this.jftCambio.setVisible(true);
          this.jftCambio.requestFocus();
         }
        // else{
        //     this.jlblMoneda.setVisible(false);
        //  this.jftCambio.setVisible(false);
        // }
    }//GEN-LAST:event_jcboMonedaActionPerformed

    private void jcbEmpresaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcbEmpresaItemStateChanged
        this.id_empresa = ((EmpresaTO)this.jcbEmpresa.getSelectedItem()).getCodigo();
    }//GEN-LAST:event_jcbEmpresaItemStateChanged

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        if(this.jCheckBox1.isSelected()){
            this.jcbEmpresa.setEnabled(true);
        } else{
            this.jcbEmpresa.setEnabled(false);
        }
        this.llenarComboEmpresa();
        //this.intelliHintsProyectos.setCompletionList(Listas.obtenerProyectosPorEmpresa(((EmpresaTO)this.jcbEmpresa.getSelectedItem()).getRuc()));
}//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jbEliminaDetalleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbEliminaDetalleActionPerformed

        try {
            if (this.jtDetallesOrden.getSelectedRow() < 0) {
                Utiles_MensajesDialogo.mensajeError("Debe elegir un detalle");
                return;
            }
            if (Utiles_MensajesDialogo.mensajeConfirmacion("Esta seguro de eliminar el detalle?"))
                eliminarFila();
        } catch (Exception e) {
            e.printStackTrace();
        }
}//GEN-LAST:event_jbEliminaDetalleActionPerformed

       private void eliminarFila() {
                String id_sumi = this.jtDetallesOrden.getValueAt(this.jtDetallesOrden.getSelectedRow(), 0).toString().trim();

                for (DetalleOrdenTO det : this.detallePedido) {
                  if (det.getSuministro().equalsIgnoreCase(id_sumi)) {
                        this.detallePedido.remove(det);
                    break;
                  }
                }
                actualizaTablaDetalle(true);
  }

    private void jbEliminaDetalleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbEliminaDetalleKeyPressed

        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbEliminaDetalle.doClick();
        }
}//GEN-LAST:event_jbEliminaDetalleKeyPressed

    private void jbAgregarDetalleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAgregarDetalleActionPerformed

       Frame frm = JOptionPane.getFrameForComponent((JInternalFrame)this);
        JDialog dialog = new JDialog(frm, true);
        dialog.setLocationRelativeTo(frm);
        dialog.setTitle("Insertar Detalles de Orden");
        dialog.setDefaultCloseOperation(0);
        String empresa=Utiles_Convertir.convertirToEmpresa_EmpresaTO((EmpresaTO)this.jcbEmpresa.getSelectedItem()).getIdEmpresa();
        jpAgregaDetalleOrdenCompra panel = new jpAgregaDetalleOrdenCompra(dialog, this,empresa);
        dialog.add(panel);
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
}//GEN-LAST:event_jbAgregarDetalleActionPerformed

    private void jbAgregarDetalleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbAgregarDetalleKeyPressed

        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbAgregarDetalle.doClick();
        }
}//GEN-LAST:event_jbAgregarDetalleKeyPressed

    private void jtfFechaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfFechaKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jtxDias.requestFocus();
        }
}//GEN-LAST:event_jtfFechaKeyPressed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        if(this.rucProveedor!=null){
             List<RegularizacionMovimientoTO> items= new ArrayList<RegularizacionMovimientoTO>(1);
            try {
                items = GestionPedidosDelegate.getInstance().getMovimientosRegularizar(this.rucProveedor);
            } catch (Exception ex) {
                Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, ex);
            }
            if(!items.isEmpty()){
                 Frame frm = JOptionPane.getFrameForComponent((JInternalFrame)this);
                 jdRegularizacionMovimientos panel = new jdRegularizacionMovimientos(frm,true,this.rucProveedor,this,items);
                 panel.setTitle("MOVIMIENTOS EN REGULARIZACION");
                 panel.setLocationRelativeTo(null);
                 panel.setVisible(true);
            }
            else
                Utiles_MensajesDialogo.mensajeAlerta("No se encontraron movimientos por regularizar");
             
        }
        else
            Utiles_MensajesDialogo.mensajeAlerta("Escoja un Proveedor");

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jbAgregaImpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAgregaImpActionPerformed
        // TODO add your handling code here:
        if(monto_redondeo.compareTo(MONTO_RDEONDEO_MAX)<0){
            monto_redondeo = monto_redondeo.add(BigDecimal.valueOf(0.01));
            monto_impuesto  = monto_impuesto.add(BigDecimal.valueOf(0.01));
            BigDecimal monto_total = BigDecimal.ZERO;
            monto_total = monto_total.add(sub_total);
            monto_total = monto_total.add(monto_impuesto);
            jlblTotal.setText(monto_total.toPlainString());
            jlblImpuesto.setText(monto_impuesto.toPlainString());
        }
    }//GEN-LAST:event_jbAgregaImpActionPerformed

    private void jbRestaImpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbRestaImpActionPerformed
        if( monto_redondeo.compareTo(MONTO_RDEONDEO_MAX.multiply(BigDecimal.valueOf(-1)))>0){
            monto_redondeo = monto_redondeo.subtract(BigDecimal.valueOf(0.01));
            monto_impuesto  = monto_impuesto.subtract(BigDecimal.valueOf(0.01));
            BigDecimal monto_total = BigDecimal.ZERO;
            monto_total = monto_total.add(sub_total);
            monto_total = monto_total.add(monto_impuesto);
            jlblTotal.setText(monto_total.toPlainString());
            jlblImpuesto.setText(monto_impuesto.toPlainString());
        }
    }//GEN-LAST:event_jbRestaImpActionPerformed

    public String getId_empresa() {
        return id_empresa;
    }

    public void setId_empresa(String id_empresa) {
        this.id_empresa = id_empresa;
    }

    
    private void llenarComboAlmacen() {
           try {
                  if (this.jcboZona.getSelectedItem() != null) {
                    ZonaTO selected = (ZonaTO)this.jcboZona.getSelectedItem();
                     
                    List listaAlmacen = null;
                    List listaAlmacen_cbo = this.cboBeanBindingAlmacen1.getLista();
                    listaAlmacen_cbo.clear();
                    listaAlmacen = Listas.getAlmacenEnZona(selected);
                    this.cboBeanBindingAlmacen1.setLista(listaAlmacen);
//                    this.bindingGroup.bind();
                    this.jcboAlmacen.updateUI();
                    this.jcboAlmacen.setSelectedIndex(0);
                  }
          }
            catch (Exception e) {
              Utiles_MensajesDialogo.mensajeAlerta("Error al obtener almacenes\n" + e.getMessage());
              e.printStackTrace();
              Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, e);
            }
     }

     private void llenarComboUbicacion() {
       try {
                  if (this.jcboAlmacen.getSelectedItem() != null) {
                    AlmacenTO selected = (AlmacenTO)this.jcboAlmacen.getSelectedItem();
                    List listaSubAlmacen = null;
                    List listaSubAlmacen_cbo = this.cboBeanBindingSubAlmacen1.getLista();
                    listaSubAlmacen_cbo.clear();
                    listaSubAlmacen = Listas.getSubAlmacenEnAlmacen(selected);
                    this.cboBeanBindingSubAlmacen1.setLista(listaSubAlmacen);
                 //   this.bindingGroup.bind();
                    this.jcboUbicacion.updateUI();
                    this.jcboUbicacion.setSelectedIndex(0);
                  }
          }
            catch (Exception e) {
              Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Sub Almacenes\n" + e.getMessage());
              e.printStackTrace();
              Logger.getLogger(jifRegistrarOrdenCompra.class.getName()).log(Level.SEVERE, null, e);
            }
     }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private administracion.BeanBinding.cboBeanBindingAlmacen cboBeanBindingAlmacen1;
    private administracion.BeanBinding.CboBeanBindingEmpresa cboBeanBindingEmpresa1;
    private administracion.BeanBinding.CboBeanBindingSubAlmacen cboBeanBindingSubAlmacen1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo2;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo3;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo4;
    private administracion.BeanBinding.CboBeanBindingZona cboBeanBindingZona1;
    private javax.swing.JButton jButton1;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbAceptar;
    private javax.swing.JButton jbAgregaImp;
    private javax.swing.JButton jbAgregarDetalle;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbEliminaDetalle;
    private javax.swing.JButton jbRestaImp;
    private javax.swing.JComboBox jcbEmpresa;
    private javax.swing.JComboBox jcboAlmacen;
    private javax.swing.JComboBox jcboFormaPago;
    private javax.swing.JComboBox jcboMoneda;
    private javax.swing.JComboBox jcboPlantillaImpuesto;
    private javax.swing.JComboBox jcboUbicacion;
    private javax.swing.JComboBox jcboZona;
    private javax.swing.JTextField jftCambio;
    private javax.swing.JLabel jlbFechaEntrega;
    private javax.swing.JLabel jlblImpuesto;
    private javax.swing.JLabel jlblMoneda;
    private javax.swing.JLabel jlblSubTotal;
    private javax.swing.JLabel jlblTotal;
    private javax.swing.JTable jtDetallesOrden;
    private javax.swing.JTextArea jtaObservaciones;
    private javax.swing.JFormattedTextField jtfFecha;
    private javax.swing.JTextField jtxDias;
    private javax.swing.JTextField jtxProveedor;
    private javax.swing.JTextField jtxReferencia;
    private javax.swing.JFormattedTextField jtxRucProveedor;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

}
